﻿/**
 * Peter
 * Created by: Peter Development Team
 *    http://peter.codeplex.com/
 * 
 * GNU General Public License version 2 (GPLv2)
 *    http://peter.codeplex.com/license
 *
 *  This code is provided on an AS IS basis, with no WARRANTIES,
 *  CONDITIONS or GUARANTEES of any kind.
 *
 **/
using System;
using System.ComponentModel;
using System.ComponentModel.Composition;
using Peter.Common.Interfaces;
using Peter.Ftp.Logic;
using Peter.Ftp.Tests.DataAccess;

namespace Peter.Ftp.Tests.Logic
{
   /// <summary>
   /// Mock for the peter options.
   /// </summary>
   [Export (typeof (IPeterOptions))]
   public class MockOptions : IPeterOptions
   {
      private readonly OptionsFtp m_FtpOptions;

      /// <summary>
      /// Initializes a new mock options object.
      /// </summary>
      public MockOptions ()
      {
         this.m_FtpOptions = new OptionsFtp { FtpConnections = { FtpConnectionTests.ConnectionData } };
      }

      /// <summary>
      /// Loaded event handlder.
      /// </summary>
      public event EventHandler Loaded;

      /// <summary>
      /// Editor options changed event handler.
      /// </summary>
      public event PropertyChangedEventHandler EditorOptionsChanged;

      /// <summary>
      /// Gets if the options are loaded or not.
      /// </summary>
      public bool IsLoaded
      {
         get { return true; }
      }

      /// <summary>
      /// Gets the requested option page.
      /// </summary>
      /// <param name="pageName">Name of option page to get.</param>
      /// <returns>The requested option page.</returns>
      public IOptionPage GetOptionPage (string pageName)
      {
         if (pageName == OptionsFtp.PAGE_NAME)
            return this.m_FtpOptions;
         return null;
      }

      /// <summary>
      /// Gets the requested option data.
      /// </summary>
      /// <param name="dataName">Name of option data to get.</param>
      /// <returns>The requested option data.</returns>
      public IOptionData GetOptionData (string dataName)
      {
         return null;
      }

      /// <summary>
      /// Triggers the loaded event.
      /// </summary>
      public void TriggerLoaded ()
      {
         if (this.Loaded != null)
            this.Loaded (this, EventArgs.Empty);
      }

      /// <summary>
      /// Triggers the editor options change event.
      /// </summary>
      public void TriggerEditorOptionsChanged ()
      {
         if (this.EditorOptionsChanged != null)
            this.EditorOptionsChanged (null, new PropertyChangedEventArgs ("Font"));
      }

      /// <summary>
      /// Saves the options.
      /// </summary>
      public void Save ()
      {
      }
   }
}
